package 第十一章_网络编程.第十一章_网络编程_MINA;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;

public class MinaclientHandler extends IoHandlerAdapter {
    @Override
    public void sessionOpened(IoSession session) throws Exception {
        super.sessionOpened(session);
        System.out.println("SessionOpened !");
    }

    @Override
    public void sessionClosed(IoSession session) throws Exception {
        super.sessionClosed(session);
        System.out.println("SessionClosed !");
    }

    @Override
    public void messageReceived(IoSession session, Object message) throws Exception {
        super.messageReceived(session, message);
        //1.文本 2.包装成对象
        //String msg=(String) message;
        Message msg=(Message) message;
        System.out.println("[echo :]"+msg.toString());
    }
}
